package one;

import java.util.Arrays;

public class GeneratePrimes {
	
	public static void main(String[] args) {
		System.out.println(generate(100000000));
	}
	
	public static double generate(int max) {
		long start = System.currentTimeMillis();
		boolean sieve[] = new boolean[max];
		Arrays.fill(sieve, true);
		sieve[0] = false;
		sieve[1] = false;
		for (long i = 2; i < Math.sqrt(max); i++) {
			if (sieve[(int) i]) {
				for (long j = 2 * i; j < sieve.length; j += i) {
					sieve[(int) j] = false;
				}
			}
		}
		return (System.currentTimeMillis() - start) / 1000.0;
	}
}
